/**
 * 
 */
package org.vsg.common.pagination.dao;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;
import org.vsg.common.pagination.GenericPaginationMaker;
import org.vsg.common.pagination.Pagination;
import org.vsg.common.pagination.PaginationException;
import org.vsg.common.pagination.PaginationMaker;
import org.vsg.common.pagination.datatrans.PaginationProvider;
import org.vsg.common.pagination.processor.AbstractPaginationProcessorHibernateDaoSupport;
import org.vsg.common.pagination.processor.PaginationProcessor;

/**
 * Implement Pagination Support Defined
 * @author Bill vison
 * @since spring 2.5
 */
@Repository
public abstract class PaginationHibernateDaoSupport extends HibernateDaoSupport {
	
	protected Pagination generatePagination(PaginationProcessor processor , PaginationProvider provider ) throws PaginationException{
		AbstractPaginationProcessorHibernateDaoSupport proc = (AbstractPaginationProcessorHibernateDaoSupport)processor;
		proc.setTemplate(this.getHibernateTemplate());
		
		PaginationMaker maker = new GenericPaginationMaker();
		maker.setProvider(provider);
		
		Pagination page = maker.newPagination(proc);
		return page;		
	}

}
